package top.caozj.conf;

import java.util.ArrayList;
import java.util.List;

/**
 * Copyright (c) 2010, 2025, xjk All rights reserved.
 *
 *  "datasource": {
 *     "type": "mysql",
 *     "url": "http://localhost:8080/api/v1/query",
 *     "username": "root",
 *     "password": "root",
 *     "tableName": "test",
 *     "sensorData": [
 *       {
 *         "sql": "select * from test",
 *         "datetime": "yyyy-MM-dd hh:mm:ss"
 *       }
 *     ]
 *   },
 * 数据源记录类
 * @author caozj thucaozj@outlook.com
 * @version 1.0
 * @date 2025-03-25
 * @since 20
 */
public class Datasource {
    private String type;
    private String url;
    private String username;
    private String password;
    private List<DataQuery> dataQueries=new ArrayList<>();

    public Datasource(String type, String url, String username, String password) {
        this.type = type;
        this.url = url;
        this.username = username;
        this.password = password;
    }

    @Override
    public String toString() {
        return "Datasource{" +
                "type='" + type + '\'' +
                ", url='" + url + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", dataQueries=" + dataQueries +
                '}';
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<DataQuery> getDataQueries() {
        return dataQueries;
    }

    public void setDataQueries(List<DataQuery> dataQueries) {
        this.dataQueries = dataQueries;
    }

    public void addDataQuery(DataQuery dataQuery) {
        this.dataQueries.add(dataQuery);
    }

//    public void addDataQuery(String sql, String datetime) {
//        this.dataQueries.add(new DataQuery(sql, datetime));
//    }
}
